let Koa = require("./application");

let app = new Koa();

// 中间键部分
// app.use(async (ctx, next) => {
//   console.log(1);
//   await next();
//   console.log(6);
// });
// app.use(async (ctx, next) => {
//   console.log(2);
//   await next();
//   console.log(5);
// });
// app.use(async (ctx, next) => {
//   console.log(3);
//   ctx.body = "hello world";
//   console.log(4);
// });

app.use(async (ctx, next) => {
  console.log(1111);
  await next();
  console.log(444);
});
app.use(async (ctx, next) => {
  console.log(2222);
  await next();
  console.log(555);
});
app.use(async (ctx, next) => {
  console.log(3333);
  await next();
  console.log(6666);
});
// 业务运行部分
app.use(async ctx => {
  console.log(ctx.request.query);
  ctx.res.writeHead(200);
  ctx.res.end("hello koa");
});
app.listen(3000, () => {
  console.log("server is start at port : 3000");
});
